<template>
  <div>
    <h1>基本信息</h1>
    ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
    <el-form ref="form" :model="form" label-width="80px">
      <tr>
        <td>
          <el-form-item label="姓名:">
            <el-input v-model="form.name" placeholder="请输入姓名"></el-input>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="性别:">
            <el-radio-group v-model="form.sex">
              <el-radio :label="1">男</el-radio>
              <el-radio :label="0">女</el-radio>
            </el-radio-group>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="手机号:">
            <el-input v-model="form.phone" placeholder="请输入手机号"></el-input>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="院校:">
            <el-input v-model="form.colleges" placeholder="请选择院校"></el-input>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="专业:">
            <el-input v-model="form.specialized" placeholder="请输入专业"></el-input>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="家庭住址:">
            <el-input v-model="form.address" placeholder="请输入家庭住址"></el-input>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="学历:">
            <el-select v-model="form.degree" placeholder="请选择学历" clearable>
              <el-option v-for="item in qw" :key="item.id" :label="item.degreeName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="政治面貌:">
            <el-input v-model="form.politicalface" placeholder="请输入政治面貌"></el-input>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="民族:">
            <el-input v-model="form.ethin" placeholder="请输入民族"></el-input>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="籍贯:">
            <el-input v-model="form.origin" placeholder="请输入籍贯"></el-input>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="婚姻:">
            <el-select v-model="form.marriage" placeholder="请选择婚姻" clearable>
              <el-option v-for="item in we" :key="item.id" :label="item.marriageName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="出生年月">
     <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="form.dateofbirth" style="width: 100%;"></el-date-picker>
    </el-col>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="邮箱:">
            <el-input v-model="form.email" placeholder="请输入邮箱"></el-input>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="身份证号:">
            <el-input v-model="form.socialsecuritynumber" placeholder="请输入身份证号"></el-input>
          </el-form-item>
        </td>
      </tr>
      <h1>职业信息</h1>
      ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
      <tr>
        <td>
          <el-form-item label="部门:">
            <el-select v-model="form.buMen" placeholder="请选择部门" clearable>
              <el-option v-for="item in options" :key="item.id" :label="item.buMenName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
        <td>
          <el-form-item label="职位:">
            <el-select v-model="form.posts" placeholder="请选择职位" clearable>
              <el-option v-for="item in opp" :key="item.id" :label="item.postsName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item label="员工状态:">
            <el-select v-model="form.type" placeholder="请选择员工状态" clearable>
              <el-option v-for="item in oo" :key="item.id" :label="item.stateName" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </td>
      </tr>
      <el-form-item>
        <el-button type="primary" @click="Update">提交</el-button>
        <el-button @click="FanHui">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data () {
    return {
      form: {
        name: '',
        sex: '',
        phone: '',
        colleges: '',
        specialized: '',
        address: '',
        degree: '',
        politicalface: '',
        ethin: '',
        origin: '',
        marriage: '',
        dateofbirth: '',
        email: '',
        socialsecuritynumber: "",
        buMen: '',
        posts: '',
        type: "",
      },
      qw: [],
      we: [],
      options: [],
      opp: [],
      oo: [],
    }
  },
  created () {
    this.BingXue();
    this.BingBu();
    this.BingZhi();
    this.BingType();
    this.BingHun();
    this.Tian();

  },
  methods: {
       Rud (val) {
      var date = new Date(val)
      return date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDay() + "日";
    },
      FanHui()
      {
          this.$router.push("/EmpSel")
      },
    select (sex) {
      this.sex = sex;
    },
    Tian () {
      var ids = localStorage.getItem("kqxq");
      this.$http({
        url: 'https://localhost:44357/api/Emp/EmpFan',
        method: "get",
        params: {
          id: ids
        }
      }).then((r) => {
        this.form = r.data
      })
    },
    Update () {
      this.$http({
        url: "https://localhost:44357/api/Emp/EmpUpdate",
        method: "post",
        data: this.form
      }).then((r) => {
        if (r.data > 0) {
          this.$notify({
            message: '这是一条成功的提示消息',
            type: 'success'
          });
          this.$router.push("EmpSel");
        }
      })
    },
    BingBu () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingBu",
        method: "get",
      }).then((r) => {
        this.options = r.data;
      })
    },
    BingZhi () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingZhi",
        method: "get",
      }).then((r) => {
        this.opp = r.data;
      })
    },
    BingType () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingType",
        method: "get",
      }).then((r) => {
        this.oo = r.data;
      })
    },
    BingXue () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingXue",
        method: "get",
      }).then((r) => {
        this.qw = r.data;
      })
    },
    BingHun () {
      this.$http({
        url: "https://localhost:44357/api/Emp/BingHun",
        method: "get",
      }).then((r) => {
        this.we = r.data;
      })
    },
  }
}
</script>